/**
 * 
 */
package com.yidu.menuProject.service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import com.yidu.menuProject.commont.Tools;
import com.yidu.menuProject.dao.FoodModelMapper;
import com.yidu.menuProject.dao.KeepModelMapper;
import com.yidu.menuProject.dao.MealModelMapper;
import com.yidu.menuProject.dao.MealtypeModelMapper;
import com.yidu.menuProject.dao.TuserModelMapper;
import com.yidu.menuProject.model.FoodModel;
import com.yidu.menuProject.model.KeepModel;
import com.yidu.menuProject.model.MealModel;
import com.yidu.menuProject.model.MealtypeModel;
import com.yidu.menuProject.model.TuserModel;

/**
 * @author Bruce
 * @date 2018年6月9日
 * @version 1.0
 */
@Service
public class MealServiceImpHWT implements MealServiceHWT{
	@Resource
	private MealModelMapper MealDao;
	@Resource
	private TuserModelMapper TuserModelDao;
	@Resource
	private MealtypeModelMapper mealtypeModelMapper;
	@Resource
	private FoodModelMapper foodModelMapper;
	@Resource
	private KeepModelMapper keepModelMapper;

	@Override
	public int deleteByPrimaryKey(String mealId) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public int insert(MealModel record) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public int insertSelective(MealModel record) {
		return MealDao.insertSelectiveHWT(record);
	}

	@Override
	public MealModel selectByPrimaryKey(String mealId) {
		
		return MealDao.selectByPrimaryKey(mealId);
	}

	@Override
	public int updateByPrimaryKeySelective(MealModel record) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public int updateByPrimaryKey(MealModel record) {
		// TODO Auto-generated method stub
		return 0;
	}
	/**
	 * 查询所有
	 */
	@Override
	public List<MealModel> selectFindAll(String da) {
			Map<String,Object> map = new HashMap<String,Object>();
			map.put("mealTypeid",da);
		 List<MealModel> list= MealDao.selectFindAll(map);
		return list;
	}
	/**
	 * 搜索框查询所有
	 */
	@Override
	public List<MealModel> selectFindAllVague(String mealName) {
		Map<String,Object> map = new HashMap<String,Object>();
		map.put("mealName",mealName);
	 List<MealModel> list= MealDao.selectFindAllVague(map);
	return list;
	}
	/**
	 * 用户注册
	 */
	@Override
	public int insertSelectiveUser(TuserModel tuserModel) {
		tuserModel.setUserId(Tools.getRandomString(16));
		return TuserModelDao.insertSelective(tuserModel);
	}
	/**
	 * 用户登录
	 */
	@Override
	public TuserModel loginUser(TuserModel tuserModel) {
		
		return TuserModelDao.loginUser(tuserModel);
	}
	
	/**
     * 查询所有商店类型
     * @return
     */
	@Override
	public List<MealtypeModel> findAllType(){
    	return mealtypeModelMapper.findAllType();
    }

	@Override
	public List<FoodModel> findAllFood(String mealId) {
		
		return foodModelMapper.selectFindAllFoodHWT(mealId);
	}
	
	@Override
	public int addKeepHWT(KeepModel km) {
		return keepModelMapper.insertSelective(km);
	}

	@Override
	public int updateKeepHWT(KeepModel km) {
		return keepModelMapper.updateByPrimaryKeySelective(km);
	}
}
